<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <meta content="IE=8" http-equiv="X-UA-Compatible" />
    <title>添加角色</title>
    {$QPath}
    <link rel="stylesheet" type="text/css" href="__TMPL__../Admin/Public/base.css" />
    <style type="text/css">
        label.item{margin-left:8px;}
        .popelist{
            float:left;
            margin:3px 6px;
            background-color:#FAFAF6;
            -moz-border-radius:4px;
            border:1px solid #aaaaaa;
            padding:8px 16px;
            width:100p\x;
        }
        .popelist li{
            line-height:20px;
            font-size:12px;
        }
        .popelist .ultitle{
            height:16px;
            line-height:16px;
            font-weight:bold;
            font-size:13px;
            padding-bottom:8px;
        }
        .popelist label{
            color:#545454;
            margin:0;
        }
    </style>
    <script type="text/javascript">
        var _validate=[
            ['name',[
                    {rule:'required',msg:'角色名称必须填写'}
                ]
            ]
        ];
    </script>
    <script type="text/javascript" src="__TMPL__../Admin/Public/mootools.js"></script>
    <script type="text/javascript" src="__TMPL__../Admin/Public/base.js"></script>
</head>
<body>
    <div id="container">
        <table class="tabmenu" cellspacing="0">
            <tbody>
                <tr>
                    <td class="wedge">&nbsp;</td>
                    <td class="wmenu"><a href="__APP__/pUser/index"><span>用户列表</span></a></td>
                    <td class="wmenu"><a href="__APP__/pUser/add"><span>添加用户</span></a></td>
                    <td class="wmenu"><a href="__URL__/index"><span>角色列表</span></a></td>
                    <td class="wmenu here">添加角色</td>
                    <td>&nbsp;</td>
                </tr>
            </tbody>
        </table>
        <div class="main">
            <ul class="fnc">
                <li>
                    <button type="button" class="btn" onclick="doSave()">保存</button>
                </li>
            </ul>
            <form id="ipsForm" method="post" action="__URL__">
                <input type="hidden" name="a"/>
                <table class="ips">
                    <tbody>
                        <tr>
                            <th class="essential"><label for="pk1">角色名称</label></th>
                            <td>
                                <input id="pk1" type="text" name="name" maxlength="32" size="40" />
                                <p class="hint">长度不能超过32个字符</p>
                            </td>
                        </tr>
                        <tr>
                            <th><label>角色状态</label></th>
                            <td>
                                <p><input id="statusOn" type="radio" name="status" value="1" checked /><label for="statusOn" class="item">启用</label></p>
                                <p><input id="statusOff" type="radio" name="status" value="0" /><label for="statusOff" class="item">禁用</label></p>
                            </td>
                        </tr>
                        <tr>
                            <th><label>权限</label></th>
                            <td>
                                <div id="popelist">
                                    <iterate name="popelist" id="bundle">
                                        <ul class="popelist">
                                            <li class="ultitle">{$bundle.name}</li>
                                            <iterate name="bundle['sub']" id="pope">
                                            <li>
                                                <input type="checkbox" name="popedom[]" id="pope{$pope.id}" value="{$pope.id}"/>
                                                <label for="pope{$pope.id}">{$pope.name}</label>
                                            </li>
                                            </iterate>
                                        </ul>
                                    </iterate>
                                </div>
                            </td>
                        </tr>
                    </tbody>
                </table>
            </form>
            <ul class="fnc">
                <li><button type="button" class="btn" onclick="doSave()">保存</button></li>
            </ul>
        </div>
    </div>
    <script type="text/javascript">
        function doSave(){
            doAction('save',{
                    submitType:'ajax',
                    ajaxOptions:{
                        runningMsg:'正在保存角色信息，请等候',
                        successMsg:'成功创建了名为<b>'+$("pk1").getProperty('value')+'</b>的角色',
                        callback:function(result,json){
                            window.location="__URL__/index";
                        }
                    }
                });
        }
        $(window).addEvent('domready',function(){
            $$('#popelist input').each(function(ips){
                ips.addEvent('change',function(){
                    var label=this.getNext('label');
                    if(this.getProperty('checked')) label.setStyle('background-color','#e8f4be');
                    else label.setStyle('background-color','transparent');
                });
            });
        });
    </script>
</body>
</html>
